import server from '@/utils/server'
import { IResult } from '../common/types'
import { IUsers, IUserListParameter } from './types'

// 获取用户列表
export const reqUserList = (UserListParameter:IUserListParameter) => {
  return server<IResult<IUsers>>({
    url: 'users',
    method: 'get',
    params: UserListParameter
  })
}

// 添加用户
export const reqAddUser = () => {
  return server({
    url: 'users',
    method: 'post'
  })
}

// 修改用户状态
export const reqUpdataUserStatus = () => {
  return server({
    url: 'users/:uId/state/:type',
    method: 'put'
  })
}

// 根据id查询用户
export const reqGetUserById = () => {
  return server({
    url: 'users/:id',
    method: 'get'
  })
}

// 编辑用户
export const reqUpdataUser = () => {
  return server({
    url: 'users/:id',
    method: 'put'
  })
}

// 根据id删除单个用户
export const reqRemoveUserById = () => {
  return server({
    url: 'users/:id',
    method: 'delete'
  })
}

// 分配用户角色
export const reqUpdataUserRole = () => {
  return server({
    url: 'user/:id/role',
    method: 'put'
  })
}
